# # # # # #  project setup  # # # # # #
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
PROJECT( osgBullet )

SET( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}" )

SET( LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single directory for all libraries." )
MAKE_DIRECTORY( ${LIBRARY_OUTPUT_PATH} )
MARK_AS_ADVANCED( LIBRARY_OUTPUT_PATH )

SET( EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single directory for all executables." )
MAKE_DIRECTORY( ${EXECUTABLE_OUTPUT_PATH} )
MARK_AS_ADVANCED( EXECUTABLE_OUTPUT_PATH )

IF( WIN32 AND MSVC )
    OPTION( WIN32_USE_MP "Build with multiple processes (/MP option; VS 2005 and above)." ON )
    MARK_AS_ADVANCED( WIN32_USE_MP )
    IF( WIN32_USE_MP )
        SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
    ENDIF( WIN32_USE_MP )
ENDIF( WIN32 AND MSVC )

INCLUDE( CMakeMacros )

FIND_PACKAGE( OSG REQUIRED )
FIND_PACKAGE( OSGWorks REQUIRED )
FIND_PACKAGE( Bullet REQUIRED )

# add bullet & osg for entire project for include & lib paths
INCLUDE_DIRECTORIES( 
    ${PROJECT_SOURCE_DIR}/include
    ${OSG_INCLUDE_DIRS}
    ${OSGWORKS_INCLUDE_DIR}
    ${BULLET_INCLUDE_DIR}
    ${BULLET_EXTRAS_INCLUDE_DIR}
)
# HACK: Not sure why this is necessary, but linket can't find osgbBulletd.lib without it.
LINK_DIRECTORIES(
    ${EXECUTABLE_OUTPUT_PATH}/Debug
)

IF( BULLET_COLLADACONVERTER_FOUND )
    ADD_DEFINITIONS( -DUSE_COLLADA )
ENDIF( BULLET_COLLADACONVERTER_FOUND )

OPTION( USE_DOUBLE_PRECISION "Use Bullet built with double precision" OFF )
IF (USE_DOUBLE_PRECISION)
    ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
ENDIF (USE_DOUBLE_PRECISION)


OPTION( BUILD_APPLICATIONS "Enable to build applications" ON )
IF( BUILD_APPLICATIONS )
    ADD_SUBDIRECTORY( applications )
ENDIF( BUILD_APPLICATIONS )

OPTION( BUILD_EXAMPLES "Enable to build example code" ON )
IF( BUILD_EXAMPLES )
    ADD_SUBDIRECTORY( examples )
ENDIF( BUILD_EXAMPLES )

OPTION( BUILD_TESTS "Enable to build test code" OFF )
IF( BUILD_TESTS )
    ADD_SUBDIRECTORY( tests )
ENDIF( BUILD_TESTS )

ADD_SUBDIRECTORY( src/osgbBullet )

ADD_SUBDIRECTORY( src/plugins )
